//
// Created by root on 20-8-9.
//

#ifndef LIBYUV_EXT_ROW_H
#define LIBYUV_EXT_ROW_H

#include <libyuv/row.h>
#include <string.h>  // For memset.

#ifdef __cplusplus
namespace libyuv {
    extern "C" {
#endif

    static __inline int RGBToY(uint8_t r, uint8_t g, uint8_t b) {
        return (66 * r + 129 * g + 25 * b + 0x1080) >> 8;
    }

    static __inline int RGBToU(uint8_t r, uint8_t g, uint8_t b) {
        return (112 * b - 74 * g - 38 * r + 0x8080) >> 8;
    }
    static __inline int RGBToV(uint8_t r, uint8_t g, uint8_t b) {
        return (112 * r - 94 * g - 18 * b + 0x8080) >> 8;
    }

    LIBYUV_API
    void BGR24ToYRow_C(const uint8_t *src_bgr, uint8_t *dst_y, int width);
    LIBYUV_API
    void BGR24ToUVRow_C(const uint8_t *src_bgr,
                        int src_stride_bgr,
                        uint8_t *dst_u,
                        uint8_t *dst_v,
                        int width);
    LIBYUV_API
    void BGR24ToYRow_NEON(const uint8_t *src_bgr, uint8_t *dst_y, int width);
    LIBYUV_API
    void BGR24ToUVRow_NEON(const uint8_t *src_bgr,
                           int src_stride_bgr,
                           uint8_t *dst_u,
                           uint8_t *dst_v,
                           int width);
    LIBYUV_API
    void BGR24ToYRow_Any_NEON(const uint8_t *src_ptr, uint8_t *dst_ptr, int width);
    LIBYUV_API
    void BGR24ToUVRow_Any_NEON(const uint8_t *src_ptr,
                               int src_stride_ptr,
                               uint8_t *dst_u,
                               uint8_t *dst_v,
                               int width);

#ifdef __cplusplus
    }  // extern "C"
}  // namespace libyuv
#endif

#endif //LIBYUV_EXT_ROW_H
